Vueless Docs
ComponentsGitHubWebsite
  • Getting Started
  • Installation
    • Quick start (Vue)
    • Quick start (Nuxt)
    • Class autocompletion
    • Minimal requirements
    • Storybook docs
  • Global customization
    • General
    • Colors
    • Design system
    • Rounding
    • Focus Outline
    • Font Size
    • Disabled Opacity
    • Dark mode
    • Custom tailwind classes
  • Component customization
    • General
    • Styling
    • Unstyled mode
    • Conditional styling
    • Extends styling from keys
    • Nested components styling
    • Props defaults
    • Redefining props
    • Defining custom props
    • Internationalization (i18n)
  • Creating own components
    • Vueless file structure
    • Create new component
    • Copy existing component
  • Svg Icons
    • General usage
    • Custom icons
    • Dynamic import
    • Advanced settings
  • Helpers
    • Change settings in runtime
  • Other
    • Vueless Vite Plugins
Powered by GitBook
On this page
  • Nested component defaults
  • Conditional default values
  1. Component customization

Props defaults

Component props such as size, color, variant, etc., have default values that can be overridden in the project's vueless.config.{js,ts}.

vueless.config.{js,ts}
export default {
  component: {
    UButton: {
      defaults: {
        size: "lg",
        color: "red",
        variant: "secondary"
      }
    }
  }
};

Nested component defaults

The config prop can also be used to redefine default prop values. In practice, this is useful for changing default values of nested components.

<UPagination 
  label="Submit" 
  :config="{ 
    activeButton: {
      defaults: { 
        size: 'xl', 
        color: 'blue'
      } 
    }
  }"
/>

In the example above, we redefine the default values for the nested UButton component within the parent UPagination component.

Conditional default values

If you need to set default values for nested components based on the parent component’s prop value, you can use an object with mapped values.

vueless.config.{js,ts}
export default {
  component: {
    UDropdownButton: {
      dropdownList: {
        defaults: {
          size: {
            "2xs": "sm",
            xs: "sm",
            sm: "sm",
            md: "md",
            lg: "lg",
            xl: "lg",
          }
        }
      }
    }
  }
};

This will conditionally set the size for the UDropdownList component based on the size value of the UDropdownButton component.

For example, if the UDropdownButton’s size prop is set to "2xs", the UDropdownList component will automatically receive a size value of "sm".

Last updated 5 months ago