Interactive playground - adjust the controls to see live updates
Basic examples showing common configurations of the dice roller component.
v-model:notation
to sync the notation with parent component state. Changes in the component automatically update the bound variable, and vice versa.
Choose between text input, dropdown select, or a combination of both.
Adjust the size and layout to fit your design needs.
Customize colors with CSS variables - no component changes needed.
Name | Type | Default | Description |
---|---|---|---|
notation |
String | '2d6' |
Initial dice notation (e.g., "2d6+3"). Supports v-model: v-model:notation |
variant |
String | 'default' |
Display variant: 'default', 'compact', or 'inline' |
input-type |
String | 'text' |
Input type: 'text', 'select', or 'combo' |
result-size |
String | 'medium' |
Result display size: 'small', 'medium', or 'large' |
show-history |
Boolean | false |
Display roll history |
show-details |
Boolean | true |
Show individual roll breakdown |
show-presets |
Boolean | false |
Show quick roll preset buttons |
minimal |
Boolean | false |
Hide notation label, show only result |
auto-roll |
Boolean | false |
Automatically roll on mount or notation change |
rules |
Array | [] |
Validation rules. Each rule: (notation) => true | false | string |
disabled |
Boolean | false |
Disable rolling (button becomes unclickable) |
loading |
Boolean | false |
Show loading state (⏳ in button, prevents rolling) |
animation-plugin |
Object | null |
Animation plugin with async roll(notation, options) method. Result displays after animation completes. |
Name | Props | Description |
---|---|---|
prepend |
{ notation, roll } |
Content before the component |
button |
{ roll } |
Custom roll button content |
result |
{ result, notation, total, rolls, modifier } |
Complete custom result display |
result-total |
{ total } |
Custom total display |
actions |
{ result, history, roll, clear } |
Action buttons area |
history-item |
{ item, index } |
Custom history item rendering |
append |
{ result, history, roll } |
Content after the component |
Name | Payload | Description |
---|---|---|
@before-roll |
{ notation: string } |
Emitted before the roll is executed |
@after-roll |
{ notation, total, rolls, modifier } |
Emitted after the roll completes successfully |
@roll |
{ notation, total, rolls, modifier } |
Emitted after roll (backwards compatibility) |
@error |
Error |
Emitted when roll fails (invalid notation) |
@validation-error |
string |
Emitted when validation rules fail |
@update:notation |
string |
Emitted when notation changes (for v-model) |
Access via template refs for programmatic control:
Name | Type | Description |
---|---|---|
roll() |
Method | Trigger a roll programmatically |
clearHistory() |
Method | Clear the roll history |
result |
Ref | Current roll result (reactive) |
history |
Ref | Roll history array (reactive) |
error |
Ref | Error message if any (reactive) |
notation |
Ref | Current notation (reactive) |
Variable | Default | Description |
---|---|---|
--dice-primary-color |
#667eea |
Primary button and accent color |
--dice-secondary-color |
#764ba2 |
Secondary gradient color |
--dice-border-radius |
4px |
Border radius for inputs and buttons |
--dice-text-color |
#333 |
Primary text color |
--dice-bg-color |
white |
Background color for inputs |
--dice-result-text |
white |
Text color in result display |