Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

785 B
Raw Blame
import { useWindowSize } from 'lib/hooks/useWindowSize'

import { LemonSegmentedButton, LemonSegmentedButtonProps } from '../LemonSegmentedButton'
import { LemonSelect, LemonSelectProps } from '../LemonSelect'

export type LemonSegmentedSelectProps<T extends string | number> = LemonSegmentedButtonProps<T> &
    LemonSelectProps<T> & {
        shrinkOn?: number
    }

export function LemonSegmentedSelect<T extends string | number>({
    shrinkOn,
    ...props
}: LemonSegmentedSelectProps<T>): JSX.Element {
    const {
        windowSize: { width = 0 },
    } = useWindowSize()

    if ((shrinkOn != null && props.options.length >= shrinkOn) || width < props.options.length * 100) {
        return <LemonSelect {...props} />
    }

    return <LemonSegmentedButton {...props} />
}