This commit is contained in:
tresabhi committed 2026-11-18 22:31:10 -06:00
1 parent 08df0001ed
commit 8cf000cbe6
12 files changed
+265 -42

No files matched your search

@@ -48,6 +48,19 @@
}
}
&[data-variant="overline"] {
border-radius: 0;
.indicator {
background: linear-gradient(var(--accent-a2), transparent);
outline: none;
border-radius: 0;
border-top: var(--space-1) solid var(--accent-9);
}
}
.option {
position: relative;
@@ -1,4 +1,5 @@
import { type ReactNode } from "react";
import { type ComponentProps, type ReactNode } from "react";
import { classNames } from "../../ui/classNames";
import styles from "./index.module.css";
export interface SegmentedControlOption {
@@ -6,12 +7,12 @@ export interface SegmentedControlOption {
label: ReactNode;
}
export interface SegmentedControlProps {
export interface SegmentedControlProps extends ComponentProps<"div"> {
options: readonly SegmentedControlOption[];
value: string;
onValueChange(value: string): void;
size?: "regular" | "minor";
variant?: "solid" | "underline";
variant?: "solid" | "underline" | "overline";
}
export function SegmentedControl({
@@ -20,19 +21,24 @@ export function SegmentedControl({
onValueChange,
size = "regular",
variant = "solid",
className,
style,
...props
}: SegmentedControlProps) {
const selectedIndex = options.findIndex((option) => option.value === value);
const segmentWidth = 100 / options.length;
return (
<div
className={styles.options}
className={classNames(styles.options, className)}
role="radiogroup"
data-size={size}
data-variant={variant}
style={{
gridTemplateColumns: `repeat(${options.length}, minmax(0, 1fr))`,
...style,
}}
{...props}
>
<div
className={styles.indicator}