Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I make my calendar occupy the half of my website? using Shadcn

I'm trying to create a scheduling appointment system, I'm trying to make the calendar occupy the half of my page, but even though I tried to increase it's height and width, it doesn't change anything.

enter image description here

Home.tsx

import { Calendar } from '@/components/ui/calendar'
import React from 'react'

export default function Home() {
  return (
    <div className='w-full  px-8'>
      <div className='flex gap-x-2'>
          <div className='flex-1 h-[650px] w-full  bg-blue-200'>
            <Calendar className='h-full w-full' />
          </div>
          <div className='flex-1'>2</div>
      </div>
    </div>
  )
}
like image 402
Stykgwar Avatar asked Nov 06 '25 06:11

Stykgwar


2 Answers

You need to modify your Home.tsx as per bellow:

import { Calendar } from "@/components/ui/calendar";
import React from "react";

export default function Home() {
  return (
    <div className="w-full  px-8">
      <div className="flex gap-x-2">
        <div className="flex-1 h-[650px] w-full  bg-blue-200">
          <Calendar
            className="h-full w-full flex"
            classNames={{
              months:
                "flex w-full flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0 flex-1",
              month: "space-y-4 w-full flex flex-col",
              table: "w-full h-full border-collapse space-y-1",
              head_row: "",
              row: "w-full mt-2",
            }}
          />
        </div>
        <div className="flex-1">2</div>
      </div>
    </div>
  );
}

For more details your can refer the docs here

like image 176
Pinal Tilva Avatar answered Nov 08 '25 22:11

Pinal Tilva


If you want to keep the margin between the calendar week rows, use the following code:

import { buttonVariants } from '@/components/ui/button';
import { Calendar } from "@/components/ui/calendar";
import React from "react";

export default function Home() {
  return (
    <div className="w-full px-8">
      <div className="flex gap-x-2">
        <div className="flex-1 h-[650px] w-full bg-blue-200">
          <Calendar
            className="h-full w-full flex"
            classNames={{
                months: 'flex w-full flex-col sm:flex-row space-y-4 sm:space-x-4 sm:space-y-0 flex-1',
                month: 'space-y-4 w-full flex flex-col',
                table: 'w-full h-full border-collapse space-y-1',
                head_cell: 'text-muted-foreground rounded-md w-8 font-normal text-[0.8rem] w-full',
                cell: cn(
                    '[&:has([aria-selected])]:bg-accent relative p-0 text-center text-sm focus-within:relative focus-within:z-20 [&:has([aria-selected].day-range-end)]:rounded-r-md',
                    '[&:has(>.day-range-end)]:rounded-r-md [&:has(>.day-range-start)]:rounded-l-md first:[&:has([aria-selected])]:rounded-l-md last:[&:has([aria-selected])]:rounded-r-md',
                    'w-full',
                ),
                day: cn(
                    buttonVariants({ variant: 'ghost' }),
                    'size-8 w-full p-0 font-normal aria-selected:opacity-100',
                ),
            }}
          />
        </div>
        <div className="flex-1">2</div>
      </div>
    </div>
  );
}
like image 35
Jacob Avatar answered Nov 08 '25 22:11

Jacob



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!