next 13 with shadcn ui progress bar example

next 13 with shadcn ui progress bar example

December 12, 2023 By Aaronn

In this tutorial, we will see how to use progress bar in next js 13 with shadcn ui. First you need to setup next js 13 with shadcn ui project.

how to use shadcn ui in next js 13


Before use progress bar in next js 13 with shadcn ui you need to install npx shadcn-ui@latest add progress.

npx shadcn-ui@latest add progress

or

npx shadcn-ui@latest add


Next 13 with Shadcn UI Progress Bar Example

1. Create next js 13 with shadcn ui progress bar using shadcn-ui Progress component.

import { Progress } from "@/components/ui/progress"

export default function ProgressDemo() {
  return (
    <div className="space-y-2">
      <Progress value={10} />
      <Progress value={25} />
      <Progress value={50} />
      <Progress value={75} />
      <Progress value={100} />
    </div>
  )
}
shadcn ui progress bar

shadcn ui progress bar

2. next js 13 with shadcn ui progress bar using useEffect, useState, setTimeout.

"use client"

import * as React from "react"

import { Progress } from "@/components/ui/progress"

export default function ProgressDemo() {
  const [progress, setProgress] = React.useState(13)

  React.useEffect(() => {
    const timer = setTimeout(() => setProgress(66), 500)
    return () => clearTimeout(timer)
  }, [])

  return <Progress value={progress} className="w-[60%]" />
}
next js 13 with shadcn ui progress

next js 13 with shadcn ui progress

3. NextJS with shadcn ui progress bar with percentage.

import { Progress } from "@/components/ui/progress"

export default function ProgressDemo() {
  return (
    <div className="space-y-4">
      <div>
        <h2 className="text-xl font-semibold mb-2 text-center">Progress Bars</h2>
        <div className="space-y-2">
          {/* 10% Progress */}
          <div className="flex items-center">
            <span className="w-1/6 text-right mr-2">10%</span>
            <div className="w-5/6">
              <Progress value={10} />
            </div>
          </div>

          {/* 25% Progress */}
          <div className="flex items-center">
            <span className="w-1/6 text-right mr-2">25%</span>
            <div className="w-5/6">
              <Progress value={25} />
            </div>
          </div>

          {/* 50% Progress */}
          <div className="flex items-center">
            <span className="w-1/6 text-right mr-2">50%</span>
            <div className="w-5/6">
              <Progress value={50} />
            </div>
          </div>

          {/* 75% Progress */}
          <div className="flex items-center">
            <span className="w-1/6 text-right mr-2">75%</span>
            <div className="w-5/6">
              <Progress value={75} />
            </div>
          </div>

          {/* 100% Progress */}
          <div className="flex items-center">
            <span className="w-1/6 text-right mr-2">100%</span>
            <div className="w-5/6">
              <Progress value={100} />
            </div>
          </div>
        </div>
      </div>
    </div>
  )
}
shadcn ui progress ui percentage

shadcn ui progress ui percentage

4. NextJS with shadcn ui progress bar with animation.

import { Progress } from "@/components/ui/progress"

export default function ProgressDemo() {
  return (
    <div className="space-y-4">
      <div>
        <h2 className="text-xl font-semibold mb-2 text-center">Progress Bars</h2>
        <div className="space-y-2">
          {/* 10% Progress */}
          <div className="flex items-center">
            <span className="w-1/6 text-right mr-2">10%</span>
            <div className="w-5/6 animate-pulse">
              <Progress value={10} />
            </div>
          </div>

          {/* 25% Progress */}
          <div className="flex items-center">
            <span className="w-1/6 text-right mr-2">25%</span>
            <div className="w-5/6 animate-pulse">
              <Progress value={25} />
            </div>
          </div>

          {/* 50% Progress */}
          <div className="flex items-center">
            <span className="w-1/6 text-right mr-2">50%</span>
            <div className="w-5/6 animate-pulse">
              <Progress value={50} />
            </div>
          </div>

        </div>
      </div>
    </div>
  )
}


Related Posts

create a accordion in nextjs 13 with shadcn ui

create sidebar in next 13 with shadcn ui

create footer section in next 13 with shadcn ui

create file upload in nextjs 13 with shadcn ui

next 13 with shadcn ui input field example

next 13 with shadcn ui cards example

next 13 with shadcn ui search bar example

next 13 with shadcn ui login page example

next 13 with shadcn ui sign up form example

next 13 with shadcn ui radio group example

next 13 with shadcn ui buttons example

next 13 with shadcn ui pagination example

next 13 with shadcn ui table example

next 13 with shadcn ui checkbox example

next 13 with shadcn ui dropdown menu example

how to use skeleton loading next 13 with shadcn ui

how to use data table next 13 with shadcn ui

how to use modal dialog next 13 with shadcn ui

how to use tabs next 13 with shadcn ui

how to use toggle switch next 13 with shadcn ui