Menus
Menu
This component is used to display content or options in a floating panel.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
1 2 3 4 5 6 7 8 9 10 11 12 13 14
1 2 3 4 5 6 7 8 9 10 11 12
1 2 3 4 5 6 7 8 9 10 11 12
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
1 2 3 4 5 6 7 8 9 10 11 12 13 14
1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
1
1 2 3 4 5 6 7 8 9 10 11 12 13 14
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59
1 2 3 4 5 6 7 8 9 10 11 12 13 14
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
1
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
1 2 3 4 5 6 7 8 9 10 11 12 13 14
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
Height Transition
Section titled Height TransitionThe --menu-height
CSS variable is exposed to enable creating smooth height transitions. The
data-transition="height"
attribute will be present when the transition is active:
Submenus
Section titled SubmenusSubmenus can be easily created by nesting menus like so:
API Reference
Section titled API ReferenceRoot
Section titled RootHTMLAttributes
Ref<MenuInstance>
Root menu container used to hold and manage a menu button and menu items. This component is used to display options in a floating panel. They can be nested to create submenus.
import { Menu } from "@vidstack/react";
const Component = Menu.Root;
type Props = Menu.RootProps;
<Menu.Root>
<Menu.Button></Menu.Button>
<Menu.Content placement="top end"></Menu.Content>
</Menu.Root>
Props
Section titled PropsProp | Type | Default |
---|---|---|
| boolean | false |
| ReactNode | null |
| number | 0 |
Callbacks
Section titled CallbacksCallback | Type |
---|---|
| function |
| function |
| function |
| function |
Instance
Section titled Instanceimport { Menu, type MenuInstance } from "@vidstack/react"
const ref = useRef<MenuInstance>(null);
useEffect(() => { /* Use props/methods here. */ }, [])
<Menu.Root ref={ref}>
Prop | Type |
---|---|
| HTMLElement |
| boolean |
| HTMLElement |
| method |
| method |
Data Attributes
Section titled Data Attributes/* Example. */
.component[data-foo] {}
Name | Description |
---|---|
| Whether this is the root menu items. |
| Whether menu is a submenu. |
| Whether menu is open. |
| Whether the menu is opened via keyboard. |
| Whether menu is disabled. |
Button
Section titled ButtonHTMLAttributes<HTMLButtonElement>
Ref<HTMLButtonElement>
A button that controls the opening and closing of a menu component. The button will become a
menuitem
when used inside a submenu.
import { Menu } from "@vidstack/react";
const Component = Menu.Button;
type Props = Menu.ButtonProps;
<Menu.Root>
<Menu.Button></Menu.Button>
<Menu.Content placement="top end"></Menu.Content>
</Menu.Root>
Props
Section titled PropsProp | Type | Default |
---|---|---|
| boolean | false |
| ReactNode | null |
| boolean | false |
Callbacks
Section titled CallbacksCallback | Type |
---|---|
| function |
Data Attributes
Section titled Data Attributes/* Example. */
.component[data-foo] {}
Name | Description |
---|---|
| Whether this is the root menu button. |
| Whether menu button is part of a submenu. |
| Whether menu is currently open. |
| Whether button is being keyboard focused. |
| Whether button is being keyboard focused or hovered over. |
Portal
Section titled PortalHTMLAttributes
Ref<HTMLElement>
Portals menu items into the given container.
import { Menu } from "@vidstack/react";
const Component = Menu.Portal;
type Props = Menu.PortalProps;
<Menu.Root>
<Menu.Button></Menu.Button>
<Menu.Portal>
<Menu.Content placement="top end"></Menu.Content>
</Menu.Portal>
</Menu.Root>
Props
Section titled PropsProp | Type | Default |
---|---|---|
| boolean | false |
| ReactNode | null |
| string | null |
| mixed | false |
Data Attributes
Section titled Data Attributes/* Example. */
.component[data-foo] {}
Name | Description |
---|---|
| Whether portal is active (determined by `disabled` prop). |
Items
Section titled ItemsHTMLAttributes
Ref<HTMLElement>
Used to group and display settings or arbitrary content in a floating panel.
import { Menu } from "@vidstack/react";
const Component = Menu.Items;
type Props = Menu.ItemsProps;
<Menu.Root>
<Menu.Button></Menu.Button>
<Menu.Items placement="top end"></Menu.Items>
</Menu.Root>
Props
Section titled PropsProp | Type | Default |
---|---|---|
| boolean | false |
| ReactNode | null |
| number | 0 |
| number | 0 |
| MenuPlacement | null |
Data Attributes
Section titled Data Attributes/* Example. */
.component[data-foo] {}
Name | Description |
---|---|
| Whether this is the root menu items. |
| Whether menu items are part of a submenu. |
| Whether menu items are currently visible. |
| Whether the menu is opened via keyboard. |
| The placement prop setting. |
| Whether item are being keyboard focused. |
| Whether items are being keyboard focused or hovered over. |
| Whether the menu is resizing. |
Item
Section titled ItemHTMLAttributes
Ref<HTMLElement>
Represents a specific option or action, typically displayed as a text label or icon, which users can select to access or perform a particular function or view related content.
import { Menu } from "@vidstack/react";
const Component = Menu.Item;
type Props = Menu.ItemProps;
<Menu.Root>
<Menu.Button></Menu.Button>
<Menu.Content placement="top end">
<Menu.Item></Menu.Item>
</Menu.Content>
</Menu.Root>
Props
Section titled PropsProp | Type | Default |
---|---|---|
| boolean | false |
| ReactNode | null |
| boolean | false |
Callbacks
Section titled CallbacksCallback | Type |
---|---|
| function |
RadioGroup
Section titled RadioGroupHTMLAttributes
Ref<RadioGroupInstance>
A radio group consists of options where only one of them can be checked. Each option is provided as a radio (i.e., a selectable element).
import { Menu } from "@vidstack/react";
const Component = Menu.RadioGroup;
type Props = Menu.RadioGroupProps;
<RadioGroup.Root>
<RadioGroup.Item value="1080">1080p</RadioGroup.Item>
<RadioGroup.Item value="720">720p</RadioGroup.Item>
</RadioGroup.Root>
Props
Section titled PropsProp | Type | Default |
---|---|---|
| boolean | false |
| ReactNode | null |
| string | '' |
Callbacks
Section titled CallbacksCallback | Type |
---|---|
| function |
Instance
Section titled Instanceimport { Menu, type RadioGroupInstance } from "@vidstack/react"
const ref = useRef<RadioGroupInstance>(null);
useEffect(() => { /* Use props/methods here. */ }, [])
<Menu.RadioGroup ref={ref}>
Prop | Type |
---|---|
| string[] |
Radio
Section titled RadioHTMLAttributes
Ref<HTMLElement>
A radio represents a option that a user can select inside of a radio group. Only one radio can be checked in a group.
import { Menu } from "@vidstack/react";
const Component = Menu.Radio;
type Props = Menu.RadioProps;
<RadioGroup.Item value="1080">1080p</RadioGroup.Item>
Props
Section titled PropsProp | Type | Default |
---|---|---|
| boolean | false |
| ReactNode | null |
| string | '' |
Callbacks
Section titled CallbacksCallback | Type |
---|---|
| function |
| function |
Data Attributes
Section titled Data Attributes/* Example. */
.component[data-foo] {}
Name | Description |
---|---|
| Whether radio is checked. |
| Whether radio is being keyboard focused. |
| Whether radio is being keyboard focused or hovered over. |