import React, { useState } from 'react';
import { Segment } from '@skeletonlabs/skeleton-react';
import { AlignLeft as IconLeft, AlignCenter as IconCenter, AlignRight as IconRight, AlignJustify as IconJustify } from 'lucide-react';
export const Page: React.FC = () => {
const [align, setAlign] = useState('left');
<Segment value={align} name="align" onChange={setAlign}>
<Segment.Item id="left" value="left">
<Segment.Item id="center" value="center">
<Segment.Item id="right" value="right">
<Segment.Item id="justify" value="justify">
This component wraps native radio inputs, which enables it to operate as as a form control.
Disabled
Set disabled
to any item to disable focus and interaction.
import React, { useState } from 'react';
import { Segment } from '@skeletonlabs/skeleton-react';
export const Page: React.FC = () => {
const [size, setSize] = useState('sm');
<Segment value={size} name="size" onChange={setSize}>
<Segment.Item id="sm" value="sm">
<Segment.Item id="md" value="md">
<Segment.Item id="lg" value="lg" disabled>
Vertical
Set flexDirection
to enable a vertical layout. This can be controlled with responsive breakpoints.
import React, { useState } from 'react';
import { Segment } from '@skeletonlabs/skeleton-react';
export const Page: React.FC = () => {
const [size, setSize] = useState('sm');
<Segment value={size} name="size" flexDirection="flex-col" onChange={setSize}>
<Segment.Item id="sm" value="sm">
<Segment.Item id="md" value="md">
<Segment.Item id="lg" value="lg" disabled>
Alternative
Consider using a Button Group if you need direct control over the markup and styling.
API Reference
Segment
Property | Type | Description |
value | string | Set the group value, which determines selection state. |
name * | string | Provide the shared input name. |
base | string | |
background | string | |
border | string | |
flexDirection | string | Set flex direction classes. |
gap | string | |
padding | string | |
rounded | string | |
width | string | |
classes | string | Provide arbitrary CSS classes. |
onChange | object | Triggers when the value state is changed. |
children | React.ReactNode | |
SegmentItems
Property | Type | Description |
id * | string | |
value * | string | Provide the unique segment value. |
title | string | Provide a hover title attribute. |
disabled | boolean | |
base | string | |
active | string | Sets active state classes. |
hover | string | Sets hover state classes. |
classes | string | Provide arbitrary CSS classes. |
labelBase | string | Sets base classes for the label element. |
labelClasses | string | Provide arbitrary CSS classes for the label element. |
onclick | object | Triggers on items click event. |
children | React.ReactNode | |