1.5.4 • Published 14 days ago

cosmo-picker v1.5.4

Weekly downloads
-
License
MIT
Repository
github
Last release
14 days ago

Cosmo Picker

Cosmo Picker is a lightweight and highly customizable date picker designed for React applications.

npm.io

New in 1.5.3 🥳

Custom Placeholder

You can now provide a custom placeholder text for the input field using the placeholder prop.

Example:

<CosmoPicker
  value={date}
  onChange={setDate}
  placeholder="Select your preferred date"
/>

Disable Date Input

Users can disable the date input using the disable prop.

Example:

<CosmoPicker value={date} onChange={setDate} disable={true} />

Installation

You can install the package via npm:

npm install cosmo-picker

You can also use yarn:

yarn add cosmo-picker

To use Cosmo Date Picker, make sure you have React and ReactDOM installed in your project. These are listed as peer dependencies, so you’ll need to install them separately if they are not already part of your project.

Below is a simple example of how to integrate Cosmo Date Picker into a React application.

import { useState } from 'react';
import { CosmoPicker } from 'cosmo-picker';

function App () {

  const [date, setDate] = useState('')

  return (
    <div>
      <CosmoPicker
        value={date}
        onChange={setDate}
      />
    </div>
  )
}

export default App

Configuration

The most basic usage of CosmoPicker is as follows:

<CosmoPicker value={date} onChange={setDate}/>

You need to provide a date value and an onChange function to handle updates. CosmoPicker operates on string-based values, so the date should be managed as a string in your state.

Props

PropertyTypeDefault ValueDescription
valuestring''The current date value in string format.
onChangefunctionundefinedCallback function triggered when the date value changes.
placeholderstring"date"The placeholder text displayed in the input field.
disablebooleanfalseDisables the date input when set to true.
iconbooleanfalseDisplays an icon at the end of the input field when set to true.
iconColorstringblackSets the color of calendar icon in the calendar.
startYearnumberundefinedDefines the first selectable year in the calendar.
endYearnumberundefinedDefines the last selectable year in the calendar.
dayBorderRadiusstring'5px'Specifies the border-radius of each day cell in the calendar view.
inputWidthstring'28rem'Sets the width of the input field, allowing flexible customization.
inputFontSizestring'1rem'Specifies the font size for the text displayed inside the input field.
inputFontWeightstring'400'Defines the font weight for the text displayed inside the input field.
inputBackgroundColorstring'white'Sets the background color of the input field.
inputTextColorstring'black'Specifies the text color inside the input field.
placeholderColorstring'#9ca3af'Sets the color of the placeholder text in the input field.
calendarBackgroundColorstring'white'Defines the background color of the calendar.
calendarFontWeightstring'600'Specifies the font weight for text displayed in the calendar.
yearBackgroundColorstring'#f3f4f6'Sets the background color for the year selection area.
calendarTextColorstring'black'Specifies the text color in the calendar.
dayBackgroundColorstring'#f3f4f6'Sets the background color for individual day cells in the calendar.
dayHoverColorstring'#d1d5db'Defines the hover color for individual day cells.
yearHoverColorstring'#d1d5db'Sets the hover color for the year selection.
selectedDayBackgroundColorstring'black'Defines the background color for the selected day.
selectedDayTextColorstring'white'Specifies the text color for the selected day.
arrowColorstring'black'Sets the color of navigation arrows in the calendar.
arrowHoverColorstring'#e5e7eb'Defines the hover color for navigation arrows.
scrollBarColorstring'#bbbbbb'Sets the color of the scroll bar within the calendar.
zIndexnumber100Sets the z-index of the date picker to control its stacking order on the page.

LICENSE

Copyright (c) 2024 Emirhan Körhan and individual contributors. Licensed under the MIT license, see LICENSE for the full license.

1.5.4

14 days ago

1.5.3

18 days ago

1.5.2

21 days ago

1.5.1

24 days ago

1.5.0

24 days ago

1.4.0

24 days ago

1.3.0

24 days ago

1.2.0

24 days ago

1.1.0

24 days ago

1.0.0

26 days ago