Shards Vue

Documentation

    Dropdowns

    You can use dropdowns to display accessible contextual overlays for displaying lists of links and more.

    Basic Example

    You can create dropdowns using the <d-dropdown> component.

    <d-dropdown text="Dropdown">
        <d-dropdown-item>Action</d-dropdown-item>
        <d-dropdown-item>Another action</d-dropdown-item>
        <d-dropdown-item>Something else here</d-dropdown-item>
        <d-dropdown-divider />
        <d-dropdown-item>Separated link</d-dropdown-item>
    </d-dropdown>
    
    <!-- dropdown-1.vue -->
    

    Theme Color

    Changing the theme color can be easily achieved using the theme prop.

    <d-dropdown text="Dropdown" theme="success">
        <d-dropdown-item>Action</d-dropdown-item>
        <d-dropdown-item>Another action</d-dropdown-item>
        <d-dropdown-item>Something else here</d-dropdown-item>
        <d-dropdown-divider />
        <d-dropdown-item>Separated link</d-dropdown-item>
    </d-dropdown>
    
    <!-- dropdown-2.vue -->
    

    Positioning

    By default dropdown menus are left aligned. However, you can change this by applying a right alignment using the right prop.

    
    <div>
        <d-dropdown text="Left Align" class="mr-2">
            <d-dropdown-item>Action</d-dropdown-item>
            <d-dropdown-item>Another action</d-dropdown-item>
            <d-dropdown-item>Something else here</d-dropdown-item>
            <d-dropdown-divider />
            <d-dropdown-item>Separated link</d-dropdown-item>
        </d-dropdown>
    
        <d-dropdown text="Right Align" right>
            <d-dropdown-item>Action</d-dropdown-item>
            <d-dropdown-item>Another action</d-dropdown-item>
            <d-dropdown-item>Something else here</d-dropdown-item>
            <d-dropdown-divider />
            <d-dropdown-item>Separated link</d-dropdown-item>
        </d-dropdown>
    </div>
    
    <!-- dropdown-3.vue -->
    

    Drop-up

    Turning dropdown menus into drop-up menus can be easily achieved using the dropup prop.

    <d-dropdown text="Dropdown" dropup>
        <d-dropdown-item>Action</d-dropdown-item>
        <d-dropdown-item>Another action</d-dropdown-item>
        <d-dropdown-item>Something else here</d-dropdown-item>
        <d-dropdown-divider />
        <d-dropdown-item>Separated link</d-dropdown-item>
    </d-dropdown>
    
    <!-- dropdown-4.vue -->
    

    Split Buttons

    Using the split prop you can create split-type dropdowns. You can hook into the click event for the left-side button.

    <template>
        <d-dropdown text="Dropdown" split @click="handleClick">
            <d-dropdown-item>Action</d-dropdown-item>
            <d-dropdown-item>Another action</d-dropdown-item>
            <d-dropdown-item>Something else here</d-dropdown-item>
            <d-dropdown-divider />
            <d-dropdown-item>Separated link</d-dropdown-item>
        </d-dropdown>
    </template>
    
    <script>
        export default {
            methods: {
                handleClick() {
                    alert('Split button was clicked!')
                }
            }
        }
    </script>
    
    <!-- dropdown-5.vue -->
    

    Sizing

    Using the size prop you can control the dropdown button's size.

    <div>
        <d-dropdown text="Large" size="lg">
            <d-dropdown-item>Action</d-dropdown-item>
            <d-dropdown-item>Another action</d-dropdown-item>
            <d-dropdown-item>Something else here</d-dropdown-item>
            <d-dropdown-divider />
            <d-dropdown-item>Separated link</d-dropdown-item>
        </d-dropdown>
    
        <d-dropdown text="Normal">
            <d-dropdown-item>Action</d-dropdown-item>
            <d-dropdown-item>Another action</d-dropdown-item>
            <d-dropdown-item>Something else here</d-dropdown-item>
            <d-dropdown-divider />
            <d-dropdown-item>Separated link</d-dropdown-item>
        </d-dropdown>
    
        <d-dropdown text="Small" size="sm">
            <d-dropdown-item>Action</d-dropdown-item>
            <d-dropdown-item>Another action</d-dropdown-item>
            <d-dropdown-item>Something else here</d-dropdown-item>
            <d-dropdown-divider />
            <d-dropdown-item>Separated link</d-dropdown-item>
        </d-dropdown>
    </div>
    
    <!-- dropdown-6.vue -->
    

    Offsets

    If you'd like to offset your dropdown menu, you can use the offset propto specify the number of pixels you would like to push the menu to either left or right depending on the value you are using (positive for pushing, negative for pulling).

    <d-dropdown text="Dropdown" offset="30">
        <d-dropdown-item>Action</d-dropdown-item>
        <d-dropdown-item>Another action</d-dropdown-item>
        <d-dropdown-item>Something else here</d-dropdown-item>
        <d-dropdown-divider />
        <d-dropdown-item>Separated link</d-dropdown-item>
    </d-dropdown>
    
    <!-- dropdown-7.vue -->
    

    Props

    PropDescriptionTypeDefaultRequired
    :idThe element ID.StringnullFalse
    :menu-idThe dropdown menu ID.StringnullFalse
    :toggle-idThe toggle ID.StringnullFalse
    :menu-classThe dropdown menu class(es).String | ArraynullFalse
    :toggle-classThe dropdown toggle class(es).String | ArraynullFalse
    :rightAlign the menu to the right.BooleanfalseFalse
    :no-caretWhether to display the caret, or not.BooleanfalseFalse
    :splitWhether to split the dropdown, or not.BooleanfalseFalse
    :themeThe color theme.String"primary"False
    :sizeThe dropdown toggle's size.StringnullFalse
    :disabledThe dropdown's disabled state.BooleanfalseFalse
    :toggle-textThe dropdown toggle's text.String"Toggle Dropdown"False
    :textThe button label's text.String""False
    :boundaryThe dropdown's boundary.String"scrollParent"False
    :offsetThe offset value.Number | StringnullFalse
    :dropupDisplay on top.BooleanfalseFalse
    :popper-optionsThe Popper options.Objectdefault() { return {}; }False
    :no-flipDisable autoflipping.BooleanfalseFalse
    :is-navWhether the dropdown is displayed inside a nav, or not.BooleanfalseFalse

    Subcomponents

    The following subcomponents are available for the <d-dropdown/> component:

    <d-dropdown-divider/>

    Props
    PropDescriptionTypeDefaultRequired
    :tagThe component tag.String"div"False

    <d-dropdown-header/>

    Props
    PropDescriptionTypeDefaultRequired
    :tagThe component tag.String"h6"False
    :idThe component ID.StringnullFalse

    <d-dropdown-item/>

    This subcomponent is inheriting Link component's props.