edtechdemo / src /components /base /Select /SelectTrigger.tsx
Nguyen Thanh Hoang
feat(dashoard): implement page dashboard (#4)
e0eaa09 unverified
'use client';
import { cn } from '@/utils/Helpers';
import { ChevronDown } from 'lucide-react';
import * as React from 'react';
import { SelectContext } from './SelectContext';
export default function SelectTrigger({ children, className }: { children: React.ReactNode; className?: string }) {
const context = React.useContext(SelectContext);
if (!context) {
throw new Error('SelectTrigger must be used within Select');
}
return (
<button
type="button"
onClick={() => context.setOpen(!context.open)}
className={cn(
'flex h-10 w-full items-center justify-between rounded-md border border-input bg-background px-3 py-2 text-sm ring-offset-background placeholder:text-muted-foreground focus:outline-none focus:ring-2 focus:ring-ring focus:ring-offset-2 disabled:cursor-not-allowed disabled:opacity-50',
className,
)}
>
{children}
<ChevronDown className="size-4 opacity-50" />
</button>
);
}