nuxt-shadcn-dashboard

repository·main·Indexed 20 days ago

https://github.com/dianprata/nuxt-shadcn-dashboard

A pre-configured Nuxt dashboard template utilizing Shadcn Vue and TailwindCSS 4. It provides a ready-to-use layout with customizable sidebar and theme settings managed via app.config.ts, including support for various UI components such as Accordion, AlertDialog, Alert, AspectRatio, AutoForm, Avatar, Badge, Breadcrumb, and ButtonGroup.

Tokens
33.9K
Snippets
114
Records
126
Agent score
70%

What's inside nuxt-shadcn-dashboard

  1. Quick Start: Initialize a new dashboard project

    main

    To create a new project based on this dashboard template, use the Nuxt CLI to initialize from the GitHub repository and then install dependencies using pnpm.

    npx nuxi@latest init -t github:dianprata/nuxt-shadcn-dashboard my-dashboard-app
    cd my-dashboard-app
    pnpm i
  2. Configure App Settings in app.config.ts

    main

    Global application settings for the sidebar and theme are managed in the app.config.ts file.

    Important: If you modify these settings, you must clear the app_settings cookie in your browser for the changes to take effect.

    export default defineAppConfig({
      appSettings: {
        sidebar: {
          collapsible: 'offcanvas', // 'offcanvas' | 'icon' | 'none'
          side: 'left', // 'left' | 'right'
          variant: 'inset', // 'sidebar' | 'floating' | 'inset'
        },
        theme: {
          color: 'default', // 'default' | 'blue' | 'green' | 'orange' | 'purple' | 'red' | 'teal' | 'yellow' | 'rose'
          type: 'scaled', // 'default' | 'mono' | 'scaled'
        }
      },
    })
  3. Configure global icon settings

    main

    You can set global defaults for the <Icon> component used throughout the dashboard. This allows you to control the default size and CSS classes applied to all icons in the application.

    export default defineAppConfig({
      icon: {
        size: '', // default <Icon> size applied
        class: '', // default <Icon> class applied
      },
    })
  4. Configure ESLint rules for nuxt-shadcn-dashboard

    main

    The project uses @antfu/eslint-config wrapped with a Nuxt-specific ESLint configuration (withNuxt). You can customize linting behavior by passing an options object to the antfu configuration function.

    Key custom rules applied in this project:

    • style/no-trailing-spaces: Set to error but configured to ignoreComments: true to allow trailing spaces in JSDoc/comments.
    • style/max-statements-per-line: Set to error with a max of 2 to relax inline statement restrictions.
    • Markdown files (**/*.md) have style/no-trailing-spaces disabled to support markdown formatting requirements.
    import antfu from '@antfu/eslint-config'
    import withNuxt from './.nuxt/eslint.config.mjs'
    
    export default withNuxt(antfu(
      {
        rules: {
          'style/no-trailing-spaces': ['error', { ignoreComments: true }],
          'style/max-statements-per-line': ['error', { max: 2 }],
        },
      },
      {
        files: ['**/*.md'],
        rules: {
          'style/no-trailing-spaces': 'off',
        },
      },
    ))
  5. Configure sidebar app settings

    main

    The appSettings.sidebar object allows you to customize the behavior and appearance of the dashboard sidebar.

    Available options:

    • collapsible: Determines how the sidebar collapses. Options are 'offcanvas' (hides completely), 'icon' (collapses to a narrow icon bar), or 'none' (fixed).
    • side: Determines which side of the screen the sidebar appears on. Options are 'left' or 'right'.
    • variant: Determines the visual style of the sidebar. Options are 'sidebar' (standard), 'floating' (detached look), or 'inset' (integrated with content padding).
    export default defineAppConfig({
      appSettings: {
        sidebar: {
          collapsible: 'offcanvas', // 'offcanvas' | 'icon' | 'none'
          side: 'left', // 'left' | 'right'
          variant: 'inset', // 'sidebar' | 'floating' | 'inset'
        },
      },
    })
  6. Reference: Sidebar and Theme configuration options

    main

    The following keys are available within the appSettings object in app.config.ts:

    Sidebar Settings

    • collapsible: Controls how the sidebar collapses. Options: 'offcanvas', 'icon', or 'none'.
    • side: Determines the sidebar position. Options: 'left' or 'right'.
    • variant: Sets the visual style of the sidebar. Options: 'sidebar', 'floating', or 'inset'.

    Theme Settings

    • color: Sets the primary theme color. Options: 'default', 'blue', 'green', 'orange', 'purple', 'red', 'teal', 'yellow', or 'rose'.
    • type: Sets the theme scaling type. Options: 'default', 'mono', or 'scaled'.
  7. Use the Pagination component suite

    main

    The pagination system is composed of several sub-components that work together to build a complete pagination UI. You should use the Pagination root component to manage the state and wrap the other sub-components to define the layout and navigation controls.

    <script setup>
    import {
      Pagination,
      PaginationContent,
      PaginationItem,
      PaginationLink,
      PaginationNext,
      PaginationPrevious
    } from '@/components/ui/pagination'
    </script>
    
    <template>
      <Pagination :total="100" :sibling-count="1">
        <PaginationContent>
          <PaginationItem>
            <PaginationPrevious />
          </PaginationItem>
          <PaginationItem>
            <PaginationNext />
          </PaginationItem>
        </PaginationContent>
      </Pagination>
    </template>
  8. Use the TagsInput component and its sub-components

    main

    The TagsInput component is a composite UI element used for managing a list of tags. It is composed of several sub-components that allow for granular control over the input area, individual tag items, and tag deletion.

    To build a complete tags input interface, you should use the following components:

    • TagsInput: The main container component.
    • TagsInputInput: The text input field used to type and add new tags.
    • TagsInputItem: The wrapper for an individual tag.
    • TagsInputItemText: The text display within a tag item.
    • TagsInputItemDelete: The button used to remove a specific tag.
    <script setup>
    import {
      TagsInput,
      TagsInputInput,
      TagsInputItem,
      TagsInputItemText,
      TagsInputItemDelete
    } from '@/components/ui/tags-input'
    
    // Note: Implementation details for state management (v-model) 
    // depend on the underlying TagsInput.vue implementation.
    </script>
    
    <template>
      <TagsInput>
        <template v-for="tag in tags" :key="tag">
          <TagsInputItem>
            <TagsInputItemText>{{ tag }}</TagsInputItemText>
            <TagsInputItemDelete />
          </TagsInputItem>
        </template>
        <TagsInputInput placeholder="Add tag..." />
      </TagsInput>
    </template>
  9. Configure the Sidebar component

    main

    The Sidebar component accepts several props to control its positioning, visual style, and behavior when collapsing.

    • side: Determines which side of the screen the sidebar appears on. Options: 'left' | 'right'.
    • variant: Defines the visual layout style. Options: 'sidebar' | 'floating' | 'inset'.
    • collapsible: Controls how the sidebar behaves when collapsed. Options: 'offcanvas' | 'icon' | 'none'.
    • class: Standard HTML attributes for custom styling.
    <Sidebar 
      side="left" 
      variant="inset" 
      collapsible="icon"
    >
      <!-- Sidebar content -->
    </Sidebar>
  10. Use the Avatar component components

    main

    The Avatar component system is composed of three main parts that work together to display a user's profile image or a fallback UI if the image fails to load:

    1. Avatar: The root container component.
    2. AvatarImage: The component responsible for rendering the user's image.
    3. AvatarFallback: The component that renders when the image is loading or fails to load (e.g., initials or a placeholder icon).

    To use them, wrap the AvatarImage and AvatarFallback inside the Avatar component.

    <script setup>
    import {
      Avatar,
      AvatarImage,
      AvatarFallback
    } from '@/components/ui/avatar'
    </script>
    
    <template>
      <Avatar>
        <AvatarImage src="https://github.com/shadcn.png" />
        <AvatarFallback>CN</AvatarFallback>
      </Avatar>
    </template>
  11. Use the Tooltip component components

    main

    The Tooltip system is composed of four main components that work together to provide contextual information on hover or focus. To use them, wrap your trigger element in a TooltipProvider, use TooltipTrigger to define the element that activates the tooltip, and place the descriptive text inside TooltipContent.

    <script setup>
    import {
      Tooltip,
      TooltipContent,
      TooltipProvider,
      TooltipTrigger
    } from '~/components/ui/tooltip'
    </script>
    
    <template>
      <TooltipProvider>
        <Tooltip>
          <TooltipTrigger>Hover me</TooltipTrigger>
          <TooltipContent>
            This is the tooltip content
          </TooltipContent>
        </Tooltip>
      </TooltipProvider>
    </template>
  12. Use the Alert component and its sub-components

    main

    The Alert component is used to display important messages or warnings. It consists of a main Alert container, an AlertTitle for the heading, and an AlertDescription for the body text. The layout automatically adjusts if an icon (SVG) is present inside the container.

    <script setup>
    import { Alert, AlertTitle, AlertDescription } from '~/components/ui/alert'
    </script>
    
    <template>
      <Alert>
        <AlertTitle>Heads up!</AlertTitle>
        <AlertDescription>
          You can add a description here.
        </AlertDescription>
      </Alert>
    </template>