HextaUI

Segmented control (UI SDK): Full width

Give the control w-full and the items share its width.

Billing period

import {
  SegmentedControl,
  SegmentedControlItem,
} from "@/components/ui/ui-sdk-segmented-control"

function UiSdkSegmentedControlFullWidth() {
  return (
    <div className="flex w-full max-w-sm flex-col gap-2">
      <p id="billing-period" className="m-0 text-sm font-medium">
        Billing period
      </p>
      <SegmentedControl
        aria-labelledby="billing-period"
        defaultValue="yearly"
        className="w-full"
      >
        <SegmentedControlItem value="monthly">Monthly</SegmentedControlItem>
        <SegmentedControlItem value="yearly">Yearly</SegmentedControlItem>
      </SegmentedControl>
    </div>
  )
}

export { UiSdkSegmentedControlFullWidth }

This adds the example as components/examples/ui-sdk-segmented-control/full-width.tsx, together with the Segmented control component and the HextaUI theme tokens it needs.

pnpm dlx shadcn@latest add https://hextaui.com/r/ui-sdk-segmented-control-full-width.json

To add only the component, follow the Segmented control installation.

Props in this example

The Segmented control props this example sets, from the API reference.

PropTypeDefault
defaultValue
T | null–
PropTypeDefault
value
string–

Every prop is in the Segmented control API reference.

See them all, with keyboard support and accessibility notes, on the Segmented control page.