diff --git a/images/gen2/lists.png b/images/gen2/lists.png new file mode 100644 index 0000000..31789da Binary files /dev/null and b/images/gen2/lists.png differ diff --git a/rayfield-gen2/elements/lists.mdx b/rayfield-gen2/elements/lists.mdx new file mode 100644 index 0000000..ab828d9 --- /dev/null +++ b/rayfield-gen2/elements/lists.mdx @@ -0,0 +1,92 @@ +--- +title: List +description: An always-visible list of options, single or multi-select. +icon: rows-3 +--- + +import Gen2SentivelBanner from '/snippets/gen2-sentivel.mdx' + + + +A list shows all options at once, with no search or collapse. Pick one, or several with `multiSelect`. + + + List element. + + +```lua +tab:CreateList({ + name = "Mods", + multiSelect = true, + options = { "Aimbot", "ESP", "Fly", "Noclip" }, + value = { "ESP" }, + callback = function(selected) + print(selected) -- { "ESP" } + end, +}) +``` + +## Properties + + + The label. + + + + Hint text under the label. Optional. + + + + An icon shown beside the label. Optional. + + + + The choices. + + + + The initial selection. A string in single mode, a table in multi. + + + + Allow more than one option at a time. + + + + Shown when nothing is selected. + + + + The save key. Optional. + + + + Skip saving. + + + + Runs with the selection. A string in single mode, a `{ string }` in multi. The table is a copy, so keeping or editing it won't affect the list. + + +## Handle + + + The current selection. Always a table, even in single mode — the choice is the first entry. + Only the callback unwraps it to a bare string in single mode. + + + + Set the selection. + + + + Replace the whole option list. Anything selected that is no longer an option is dropped (single-select picks the first new option automatically), and the callback runs if that changed the selection. + + + + Add one option. + + + + Remove one option. Removing a selected one clears it from the selection and runs the callback. +