Buttons & links
Button
Section titled “Button”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),]);- align:null
- direction:"row"
- float:null
- gap:"sm"
- height:null
- justify:null
- width:null
- buttonType:"button"
- effects:[]
- href:null
- icon:null
- label:"Default"
- variant:"default"
- buttonType:"button"
- effects:[]
- href:null
- icon:null
- label:"Secondary"
- variant:"secondary"
- buttonType:"button"
- effects:[]
- href:null
- icon:null
- label:"Success"
- variant:"success"
- buttonType:"button"
- effects:[]
- href:null
- icon:null
- label:"Info"
- variant:"info"
- buttonType:"button"
- effects:[]
- href:null
- icon:null
- label:"Destructive"
- variant:"destructive"
- buttonType:"button"
- effects:[]
- href:null
- icon:null
- label:"Outline"
- variant:"outline"
- buttonType:"button"
- effects:[]
- href:null
- icon:null
- label:"Ghost"
- variant:"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');Segmented control
Section titled “Segmented control”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');- emits:"appearance-changed"
- label:"Appearance"
- name:"appearance"
- options:[{"label":"Light","value":"light"},{"label":"Dark","value":"dark"},{"label":"System","value":"system"}]
- value:"light"