Skip to content

Buttons & links

Button::make($label) renders a button. Style it with ->variant(): Default, Secondary, Success, Info, Destructive, Outline, Ghost, or Link (see ButtonVariant).

Stack::make()->direction('row')->gap(Gap::Small)->schema([
Button::make('Default')->variant(ButtonVariant::Default),
Button::make('Secondary')->variant(ButtonVariant::Secondary),
Button::make('Success')->variant(ButtonVariant::Success),
Button::make('Info')->variant(ButtonVariant::Info),
Button::make('Destructive')->variant(ButtonVariant::Destructive),
Button::make('Outline')->variant(ButtonVariant::Outline),
Button::make('Ghost')->variant(ButtonVariant::Ghost),
]);

A button does one of a few things depending on how you configure it:

  • ->href($url) renders it as a link.
  • ->submit() makes it a form’s submit control — see Forms.
  • ->icon($name) adds a sprite icon before the label.
  • ->effects(Effect::…) dispatches client-side effects on click with no request to the server, e.g. ->effects(Effect::toggleSidebar('app-sidebar')).

To run a server action on click, use an Action rather than a plain button.

Link::make($label)->href($url) renders a navigational link. It navigates through Inertia by default, takes an ->icon($name), and supports affixes. It can also trigger an action instead of navigating.

Link::make('Documentation')->href('https://latticephp.com');

SegmentedControl::make($name, $label?) renders single-select pills that live outside a form and emit a client event when the selection changes — reach for it for client-side settings like an appearance switcher, not as a form field (use Choice for that). Give it ->options([...]), an initial ->value(), and ->emits($event) to name the window event dispatched on change (its detail carries { name, value }).

SegmentedControl::make('appearance', 'Appearance')
->options([
SegmentedControl::option('Light', 'light'),
SegmentedControl::option('Dark', 'dark'),
SegmentedControl::option('System', 'system'),
])
->value('light')
->emits('appearance-changed');