Learn
Core concepts
These are the Vue ideas you will see on component pages. Start with the first example; come back to the others when you need them.
Props change a component
A prop is a value you pass to a component. Here, variant changes how Button looks, and size changes its height. If you leave them out, Button uses its defaults.
<script setup lang="ts">
import Button from './components/ui/button/Button.vue'
</script>
<template>
<Button variant="outline" size="sm">Cancel</Button>
</template>A model holds a value
v-model connects a component's value to a Vue variable. Typing in this Input changes email, and changing email updates the Input. Use a ref when your page needs to react to that value.
<script setup lang="ts">
import { ref } from 'vue'
import Input from './components/ui/input/Input.vue'
const email = ref('')
</script>
<template>
<label for="email">Email</label>
<Input id="email" v-model="email" type="email" />
<p>You entered: {{ email }}</p>
</template>Events tell your page what happened
@click runs your function when someone activates Button. Other components emit events such as change or update:open. Each component's API reference lists its events.
<script setup lang="ts">
import Button from './components/ui/button/Button.vue'
function save() {
// Save your data here.
}
</script>
<template>
<Button @click="save">Save</Button>
</template>Slots hold your content
The words between <Button> and </Button> are the Button's default slot. Some components also have named slots for a prefix, suffix, actions, or other content. A slot lets you provide your own text or markup without changing the component's behavior.
<script setup lang="ts">
import Button from './components/ui/button/Button.vue'
</script>
<template>
<Button>
<template #prefix><span aria-hidden="true">+</span></template>
Add item
</Button>
</template>“Add item” is the label in the default slot. The plus sign goes in the named prefix slot; aria-hidden keeps that decorative sign out of the spoken label.
Compound components work together
Some controls have several named parts. Dialog owns whether it is open; DialogTrigger opens it; DialogContent holds the content; DialogTitle names it. Keeping the parts separate lets you arrange real content while Dialog manages focus and keyboard behavior.
<script setup lang="ts">
import Dialog from './components/ui/dialog/Dialog.vue'
import DialogTrigger from './components/ui/dialog/DialogTrigger.vue'
import DialogContent from './components/ui/dialog/DialogContent.vue'
import DialogTitle from './components/ui/dialog/DialogTitle.vue'
</script>
<template>
<Dialog>
<DialogTrigger>Open settings</DialogTrigger>
<DialogContent>
<DialogTitle>Settings</DialogTitle>
<p>Put your settings here.</p>
</DialogContent>
</Dialog>
</template>The source lives in your app
The Weini CLI copies component files into your project. You import those files directly. You can inspect and edit them like any other source code. weini.json records what was installed so you can check for updates later.
Choose by interaction
| Need | Component | Choose it when |
|---|---|---|
| One value from a fixed list | Select | The user chooses an option without typing a query. |
| Searchable single value | Combobox | The user can type to filter or find one option. |
| Several values from a list | MultiSelect | The user can commit and remove multiple options. |
| Need | Component | Choose it when |
|---|---|---|
| Inline date grid | Calendar | Dates belong directly in the page. |
| One date in a field | DatePicker | A single date is the field value. |
| Start and end dates | DatePickerRange | The value is a date range. |
| Date and time in one field | DateTimePicker | The value is one local date-time. |
| Time without a date | TimePicker | The value is a time of day. |
| Need | Component | Choose it when |
|---|---|---|
| Commands opened by a button | DropdownMenu | Actions belong to a specific trigger. |
| Commands at the pointer or long press | ContextMenu | Actions depend on the content that was invoked. |
| Persistent desktop command groups | Menubar | The app uses a menu bar with top-level groups such as File and Edit. |
| Site or app section navigation | NavigationMenu | The open panel contains links between sections or pages. |
Ready to build? Browse all components or return to Getting started.