Pallas UI
DocsComponents
Core Concepts
    • Introduction
    • Getting Started
    • Theming
    • Color Tokens
    • Spacing & Sizing
    • Layout Guide
    • AspectRatio
    • Box
    • Flex
    • Grid
    • Shapes
Previews
    • Accordion
    • Alert
    • Avatar
    • Badge
    • Breadcrumb
    • Button
    • Carousel
    • Checkbox
    • Combobox
    • Command
    • Date Picker
    • Form
    • Input
    • Input OTP
    • Label
    • MenuBar
    • Modal
    • Popover
    • Progress
    • Radio Group
    • Segmented
    • Select
    • Separator
    • Sheet
    • Sidebar
    • Skeleton
    • Slider
    • Spinner
    • Steps
    • Switch
    • Tabs
    • Textarea
    • Toast
    • Tooltip
    • Typography
  1. Components
  2. Segmented

Segmented

Interactive elements where selection is presented in a way that suggests a tab-like view.

Installation

Install the following dependencies

npm install @radix-ui/react-tabs

Copy and paste the following code into your project

'use client'
 
import type { Assign, WithFixedClassName } from '@pallas-ui/style-context'
import * as Tabs from '@radix-ui/react-tabs'
import type { SegmentedVariantProps } from '@styled-system/recipes'
import type { ComponentProps, JsxStyleProps } from '@styled-system/types'
import type * as React from 'react'
import { Root, withContext } from './root'
 
export type RootProps = Assign<
  WithFixedClassName<ComponentProps<typeof Tabs.Root>>,
  SegmentedVariantProps & JsxStyleProps
>
 
export const Option = withContext<
  React.ComponentRef<typeof Tabs.Trigger>,
  Assign<WithFixedClassName<ComponentProps<typeof Tabs.Trigger>>, JsxStyleProps>
>(Tabs.Trigger, 'option')
 
export const Text = withContext<
  React.ComponentRef<'p'>,
  Assign<WithFixedClassName<ComponentProps<'p'>>, JsxStyleProps>
>('p', 'text')
 
const Segmented = {
  Root,
  Option,
  Text,
}
 
export default Segmented
import { createStyleContext } from '@pallas-ui/style-context'
import * as Tabs from '@radix-ui/react-tabs'
import { segmented } from '@styled-system/recipes'
import type { RootProps } from '.'
 
export const { withProvider, withContext } = createStyleContext(segmented)
 
const Component = withProvider<React.ElementRef<typeof Tabs.Root>, RootProps>(Tabs.Root, 'root')
 
export const Root = ({ children, ...props }: RootProps) => {
  return (
    <Component {...props} asChild>
      <Tabs.List>{children}</Tabs.List>
    </Component>
  )
}

Update the import paths to match your project setup

Usage

import Segmented from '@/components/ui/segmented'
const [value, setValue] = useState('tab1')
 
<Segmented.Root value={value} onValueChange={setValue}>
  <Segmented.Option value="tab1">
    <Segmented.Text>Option 1</Segmented.Text>
  </Segmented.Option>
  <Segmented.Option value="tab2">
    <Segmented.Text>Option 2</Segmented.Text>
  </Segmented.Option>
  <Segmented.Option value="tab3">
    <Segmented.Text>Option 3</Segmented.Text>
  </Segmented.Option>
</Segmented.Root>

Examples

Sizes

Orientation

Block (Full Width)

Disabled

With Icons

Built with ❤️ by the carbonteq team. The source code is available on GitHub.

© 2025 Pallas UI. All rights reserved.