ElementRef
A ref is a handle on a rendered element, and the only way to read where an element ended up on screen or to move a container's scroll position. Every class on this page is reached through one.
ElementRef
final class Phui\Refs\ElementRef
A handle on a rendered element. Declared with the #[Ref] attribute and attached to a node with ref().
isBound(): boolReturns whether the ref is attached to a rendered element. False before the first render.
scroll(): ScrollApiReturns the ScrollApi for the bound element.
layout(): LayoutApiReturns the LayoutApi for the bound element.
ScrollApi
final class Phui\Layout\ScrollApi
Reads and moves a scrollable container's viewport.
offset(): PointReturns the current scroll offset.
viewport(): SizeReturns the size of the visible region.
content(): SizeReturns the size of the full scrollable content.
by(int $dx, int $dy): voidMoves the offset by $dx columns and $dy rows.
to(int $x, int $y): voidMoves the offset to an absolute position.
intoView(int $index, ?AlignmentType $align = null): voidScrolls the child at $index into the visible region. By default it scrolls the least it can, leaving a child that is already visible where it is. Pass an AlignmentType to place the child at a fixed spot instead.
LayoutApi
final readonly class Phui\Layout\LayoutApi
rect(): RectReturns the element's box on screen, including its border and padding.
contentRect(): RectReturns the box available to the element's content, inside its border and padding.
Rect
final class Phui\Layout\Rect
__construct(
public Point $position,
public Size $size,
public ?Size $minSize = null,
public ?Size $maxSize = null,
)Creates a rectangle from a position and size, with optional clamps.
contains(int $x, int $y): boolReturns whether the cell at $x, $y falls inside the rectangle.
intersect(Rect $other): RectReturns the overlap between this rectangle and $other.
Point
final class Phui\Layout\Point
__construct(
public int $x = 0,
public int $y = 0,
)Creates a column and row position.
Size
final class Phui\Layout\Size
__construct(
public ?int $width = null,
public ?int $height = null,
)Creates a width in columns and height in rows. Either may be null when undetermined.