All Projects → agutoli → React Styled Select

agutoli / React Styled Select

Licence: mit
A Select control built with Reactjs, styled-components and ❤️ http://agutoli.github.io/

Programming Languages

javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to React Styled Select

personal-blog
✍️ 个人技术博客
Stars: ✭ 79 (-23.3%)
Mutual labels:  styled-components, css3
react-functional-select
Micro-sized & micro-optimized select component for React.js
Stars: ✭ 165 (+60.19%)
Mutual labels:  select, styled-components
Leaf Ui
🍃 Leaf-UI: A react component library built using styled-components
Stars: ✭ 98 (-4.85%)
Mutual labels:  styled-components
Gatsby Starter Cv
A simple starter to get up and developing your digital curriculum with GatsbyJS
Stars: ✭ 103 (+0%)
Mutual labels:  styled-components
Customalertviewdialogue
Custom AlertView Dialogue is the world's most advanced alert view library. Custom AlertView Dialogue includes simple message popups, confirmation alerts, selector popups, action sheet bottom menus, and input/feedback contact forms.
Stars: ✭ 100 (-2.91%)
Mutual labels:  select
Softuni
SoftUni Courses
Stars: ✭ 98 (-4.85%)
Mutual labels:  css3
Re Jok
A React UI Component library built with styled-components
Stars: ✭ 102 (-0.97%)
Mutual labels:  styled-components
Gitpedia
A web application to 🔍 view a github's user profile in a more simple and beautiful way. Built using React, Chart JS 📊 , styled components 💅 and more 📦
Stars: ✭ 98 (-4.85%)
Mutual labels:  styled-components
Nanostyled
A <1kB library for styling React components as if with CSS-in-JS, without CSS-in-JS
Stars: ✭ 104 (+0.97%)
Mutual labels:  styled-components
Downshift
🏎 A set of primitives to build simple, flexible, WAI-ARIA compliant React autocomplete, combobox or select dropdown components.
Stars: ✭ 10,183 (+9786.41%)
Mutual labels:  select
Css In React
🍭 CSS in React - Learn the best CSS in JS frameworks by example
Stars: ✭ 101 (-1.94%)
Mutual labels:  styled-components
Nodeppt
This is probably the best web presentation tool so far!
Stars: ✭ 9,589 (+9209.71%)
Mutual labels:  css3
Griz
Grid library for React; Rescue the cat
Stars: ✭ 99 (-3.88%)
Mutual labels:  styled-components
Selection
✨ Selection - A simple and lightweight library to add a visual way of selecting elements, just like on your Desktop. Zero dependencies. Full mobile and scroll support.
Stars: ✭ 1,371 (+1231.07%)
Mutual labels:  select
Clever Bootstrap 4 Admin Template With Angularjs Angular 2 Support
Clever is Boostrap 4 Admin Template with Angular 2 and AngularJS support
Stars: ✭ 98 (-4.85%)
Mutual labels:  css3
React Bootstrap Webpack Starter
ReactJS 16.4 + new React Context API +react Router 4 + webpack 4 + babel 7+ hot Reload + Bootstrap 4 + styled-components
Stars: ✭ 103 (+0%)
Mutual labels:  styled-components
Terminal layout
The project help you to quickly build layouts in terminal,cross-platform(一个跨平台的命令行ui布局工具)
Stars: ✭ 98 (-4.85%)
Mutual labels:  select
Bootstrap Select
🚀 The jQuery plugin that brings select elements into the 21st century with intuitive multiselection, searching, and much more.
Stars: ✭ 9,442 (+9066.99%)
Mutual labels:  select
Rtlcss
Framework for transforming Cascading Style Sheets (CSS) from Left-To-Right (LTR) to Right-To-Left (RTL)
Stars: ✭ 1,363 (+1223.3%)
Mutual labels:  css3
Feathericons.com
The Feather website
Stars: ✭ 104 (+0.97%)
Mutual labels:  styled-components

Issues License Build Status NPM

react-styled-select

Up to date with react/react-dom 16.2.0 and styled-components 4.1.1

ATTENTION: Work in Progress (sorry about that!)

This project was built with styled-components and is a "rethink" of the awesome project react-select. But what the differences between react-select and this project?

  • Lightweight!
  • It don`t force you to load any external css.
  • Works with css-modules concept and not with global class names. Here has a good discussion about this problem (here).
  • CSS Variables: Very easy to customize for your need.
  • Shadow DOM: If you has or had problems with input fields globally stylized you can "encapsulate" your component using this awesome feature.

Installation

npm install react-styled-select --save

Demo

http://agutoli.github.io/

Example Usage

import React from 'react'
import Select from 'react-styled-select'

class MyComp extends React.Component {
  render() {
    const options = [
      { label: "One", value: 1},
      { label: "Two", value: 2},
    ]
    return (
      <Select
        options={options}
        onOpen={myOpenFunc}
        onChange={myChangeFunc}
        classes={{
          selectValue: 'my-custom-value',
          selectArrow: 'my-custom-arrow'
        }}
      />
    )
  }
}

Opptions

Property Type Default Description
classes object undefined You can specify className for each element. Possible values: selectArrow, selectArrowZone, selectClear, selectClearZone, selectControl, selectInput, selectInputField, selectMenu, selectMenuOuter, selectMultiValueWrapper, selectOption, selectPlaceholder, selectValue, selectValueLabel
clearable bool false should it be possible to reset value
disabled bool false disables every events over the component
multi bool false multi values support
virtualized bool false (NEW) efficiently rendering large lists options
virtualizedMaxHeight number 198 (NEW) height of option menu
virtualizedOptionHeight number 38 (NEW) Height of each options
searchable bool true whether to enable searching feature or not
placeholder string Select... The short hint is displayed in the input field before the user enters a value
loadOptions function undefined function that returns a promise or calls a callback with the options: function(input, [callback])
className string undefined Root element className
value any undefined If you want to specify a pre selected value
options array [] List of values. Ex.
[{"label": "Foo", value: "foo"}]
onOpen function undefined It calls when open outer menu
onChange function undefined It calls when change selected value
onValueClick function undefined It calls when click over a option value
closeMenuOnSelect function undefined It calls when click over a option value
onInputClear function undefined It calls when input is cleared
valueRenderer function undefined function which returns a custom way to render the value selected function (option) {}
optionRenderer function undefined function which returns a custom way to render the options in the menu (option) {}

Async options (NEW)

Very similar with react-select API.

var getOptions = function(input, callback) {
  setTimeout(function() {
    callback(null, {
      options: [
        { value: 'one', label: 'One' },
        { value: 'two', label: 'Two' }
      ]
    });
  }, 500);
};

<Select.Async
    loadOptions={getOptions}
/>

Custom appearance with CSS Variebles

Multi Select (NEW)

Default

Customized

  • Your react file ex. MyForm.jsx
class MyForm extends React.Component {
  render() {
    return(){
      <Select className="dark-theme" options={[...]} />
    }
  }
}
  • Your project CSS file ex. mysite.css
.dark-theme {
  --styled-select-placeholder__color: #999;
  --styled-select__color: white;
  --styled-select__background-color: #555;
  --styled-select__border-color: black;
  --styled-select__border-width: 3px;
  --styled-select__border-radius: 5px;

  --styled-select-menu-outer__margin: 10px 0 0 0;
  --styled-select-menu-outer__padding: 0;
  --styled-select-menu-outer__background-color: #555;
  --styled-select-menu-outer__border-color: black;
  --styled-select-menu-outer__border-style: solid;
  --styled-select-menu-outer__border-width: 3px;

  --styled-select-option__background-color: #444;

  --styled-select-option__color--focused: #eee;
  --styled-select-option__background-color--focused: #333;

  --styled-select-option__color--selected: #eee;
  --styled-select-option__background-color--selected: #444;
}

Available CSS variables

--styled-select-arrow-zone__width: 25px;

--styled-select-arrow__color: #9b9ba5;
--styled-select-arrow__size: 8;

--styled-select-clear-zone__width: 17px;

--styled-select-clear__color: #999;
--styled-select-clear__font-size: 14px;

--styled-select-control__border-color: #dcdce3;
--styled-select-control__border-color--focused: #40a3f5;
--styled-select-control__cursor--disabled: not-allowed;
--styled-select-control__min-height: 36px;

--styled-select-input__height: 23px;
--styled-select-input__line-height: 23px;
--styled-select-input__padding: 0;

--styled-select-menu-outer__background-color: #fff;
--styled-select-menu-outer__border-color: #f0f0f5;
--styled-select-menu-outer__border-radius: 2px;
--styled-select-menu-outer__border-style: solid;
--styled-select-menu-outer__border-width: 1px;
--styled-select-menu-outer__box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
--styled-select-menu-outer__margin: 5px 0 0 0;
--styled-select-menu-outer__max-height: 200px;
--styled-select-menu-outer__padding: 0;

--styled-select-menu__border-radius: 2px;
--styled-select-menu__max-height: 198px;

--styled-select-multi-value-wrapper__padding: 3px 0 3px 5px;

--styled-select-multi-value__background-color: #eee;
--styled-select-multi-value__border: 1px solid #aaa;
--styled-select-multi-value__border--hover: 1px solid #777;
--styled-select-multi-value__border-radius: 3px;
--styled-select-multi-value__box-shadow: rgba(0,0,0,0.2) 0px 0px 3px;
--styled-select-multi-value__font-size: 0.9em;
--styled-select-multi-value__line-height: 1.4;
--styled-select-multi-value__margin: 2px 5px 2px 0;

--styled-select-no-results__color: #999;
--styled-select-no-results__font-family: Tahoma, Helvetica, Arial, sans-serif;
--styled-select-no-results__font-size: 14px;
--styled-select-no-results__padding: 8px 10px;

--styled-select-option__background-color: #fff;
--styled-select-option__background-color--focused: #f0f0f5;
--styled-select-option__background-color--selected: #ddd;
--styled-select-option__color: #777;
--styled-select-option__color--focused: #333;
--styled-select-option__color--selected: #333;
--styled-select-option__font-family: Tahoma, Helvetica, Arial, sans-serif;
--styled-select-option__padding: 8px 10px;

--styled-select-placeholder__color: #d2d2d9;
--styled-select-placeholder__font-family: Tahoma, Helvetica, Arial, sans-serif;
--styled-select-placeholder__font-size: 12px;
--styled-select-placeholder__line-height: 34px;
--styled-select-placeholder__padding: 0 10px;

--styled-select-value-icon__background-color: transparent;
--styled-select-value-icon__background-color--hover: rgba(0, 0, 0, 0.1);
--styled-select-value-icon__font-family: arial;
--styled-select-value-icon__padding: 1px 5px;

--styled-select-value-label__font-family: Tahoma, Helvetica, Arial, sans-serif;
--styled-select-value-label__padding: 1px 6px;

--styled-select-value-wrapper__align-content: space-around;
--styled-select-value-wrapper__align-items: center;
--styled-select-value-wrapper__box-sizing: border-box;
--styled-select-value-wrapper__display: flex;
--styled-select-value-wrapper__flex: 2 100%;
--styled-select-value-wrapper__padding: 0 0 0 5px;

--styled-select-value__color: Tahoma, Helvetica, Arial, sans-serif;
--styled-select-value__font-size: 14px;
--styled-select-value__line-height: 34px;
--styled-select-value__max-width: 100%;
--styled-select-value__overflow: hidden;
--styled-select-value__padding: 0 5px;
--styled-select-value__text-overflow: ellipsis;
--styled-select-value__white-space: nowrap;

--styled-select__background-color: #fff;
--styled-select__border-radius: 2px;
--styled-select__border-style: solid;
--styled-select__border-width: 1px;
--styled-select__box-sizing: border-box;
--styled-select__color: #777;
--styled-select__cursor--disabled: not-allowed;
--styled-select__opacity--disabled: 0.5;
--styled-select__pointer-events--disabled: none;
--styled-select__position: relative;

Inspiration

This project was based on react-select.

Collaborators

Special thanks to:

License

The MIT License (MIT)

Copyright (c) 2017-2018 Bruno Agutoli

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].