ui icon indicating copy to clipboard operation
ui copied to clipboard

[Suggestion] Split button component

Open zisra opened this issue 2 years ago • 1 comments

Something like this

zisra avatar Jul 02 '23 14:07 zisra

There is one one the main page of the front page. So it can certainly be done already by composing components.

https://ui.shadcn.com/examples/cards

Capture d’écran 2024-01-22 à 16 21 43 Capture d’écran 2024-01-22 à 16 21 49

Yohannfra avatar Jan 22 '24 15:01 Yohannfra

For anyone coming to this issue, like I did, here's some code that'll do the trick:

<div className="flex items-center">
  <Button variant="outline" className={'rounded-r-none'}>
    Create file
  </Button>
  <DropdownMenu>
    <DropdownMenuTrigger asChild>
      <Button variant="outline" className={'rounded-l-none border-l-0 px-2'}>
        <CaretDownIcon />
      </Button>
    </DropdownMenuTrigger>
    <DropdownMenuContent>
      <DropdownMenuItem>Create sheet</DropdownMenuItem>
      <DropdownMenuItem>Create doc</DropdownMenuItem>
      <DropdownMenuItem>Create thingy</DropdownMenuItem>
    </DropdownMenuContent>
  </DropdownMenu>
</div>

It's essentially two buttons, side-by-side, with their borders and styles tweaked.

You can easily imagine extending this with an icon or tweaking the dropdown as you so please.

jimniels avatar Feb 16 '24 00:02 jimniels

Thank you. Closed.

zisra avatar Feb 16 '24 00:02 zisra