All Projects → ihor → react-styled-floating-label

ihor / react-styled-floating-label

Licence: MIT license
Floating label component which works with any HTML input

Programming Languages

typescript
32286 projects
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to react-styled-floating-label

jss-material-ui
A enhanced styling engine for material-ui
Stars: ✭ 15 (-54.55%)
Mutual labels:  styled-components, styled
nebuchadnezzar
on the way to cleanest react architechture
Stars: ✭ 15 (-54.55%)
Mutual labels:  styled-components, styled
foliage
🍃 Style your components with performance
Stars: ✭ 29 (-12.12%)
Mutual labels:  styled-components, styled
shorted-theme
Shorted theme references for Styled Components.
Stars: ✭ 13 (-60.61%)
Mutual labels:  styled-components, styled
Styled-Responsive-Media-Queries
Responsive Media Queries for Emotion styled or styled-components — Standard size from Chrome DevTools.
Stars: ✭ 33 (+0%)
Mutual labels:  styled-components, styled
Goober
🥜 goober, a less than 1KB 🎉 css-in-js alternative with a familiar API
Stars: ✭ 2,317 (+6921.21%)
Mutual labels:  styled-components, styled
react-library-starter
A library starter kit and bundler for your React projects, powered by Rollup. ⚡
Stars: ✭ 22 (-33.33%)
Mutual labels:  styled-components
Frontend
마음을 잇는 현명한 소비 '잇다'🤝
Stars: ✭ 19 (-42.42%)
Mutual labels:  styled-components
proffy
React Native + ReactJS + NodeJS project developed on RocketSeat NexLevelWeek. This project is based on an application for connect students and teachers.
Stars: ✭ 30 (-9.09%)
Mutual labels:  styled-components
design-system
Strapi.io's design system 🚀
Stars: ✭ 262 (+693.94%)
Mutual labels:  styled-components
app-intro-lottie-expo
App Intro component with Expo, styled-components and Lottie
Stars: ✭ 46 (+39.39%)
Mutual labels:  styled-components
components
Components library for the Blockchain.com ecosystem 💍 🔥
Stars: ✭ 20 (-39.39%)
Mutual labels:  styled-components
lewis-gatsby-starter-blog
A custom Gatsby starter template to start a blog or personal website.
Stars: ✭ 34 (+3.03%)
Mutual labels:  styled-components
reactpeople
React People lists and connects React developers around the world.
Stars: ✭ 15 (-54.55%)
Mutual labels:  styled-components
2019.hackthenorth.com
Hack the North 2019's main website.
Stars: ✭ 52 (+57.58%)
Mutual labels:  styled-components
svelte-multistep-form
Svelte MultiStep Form like, this component is still in beta stage
Stars: ✭ 29 (-12.12%)
Mutual labels:  styled-components
razzle-template
SSR template with React, Effector, TypeScript, ReactRouter, and StyledComponents
Stars: ✭ 62 (+87.88%)
Mutual labels:  styled-components
lifemanager
⏱ 한 일을 기록하면 시각화 해서 보여주는 웹 앱⏱
Stars: ✭ 85 (+157.58%)
Mutual labels:  styled-components
sugui
UI Components library based on React, Styled Components and React Testing Library
Stars: ✭ 17 (-48.48%)
Mutual labels:  styled-components
react-components-kit
A collection of reusable and themable React UI components built with styled-components
Stars: ✭ 14 (-57.58%)
Mutual labels:  styled-components

React-Styled-Floating-Label

Floating label component which works with any HTML input. Supports styling with styled-components. Check this live demo to see it in action.

import FloatingLabel from 'react-styled-floating-label';

const email = (
    <FloatingLabel text="Email">
        <input type="email" />
    </FloatingLabel>
);

Installation

npm i react-styled-floating-label styled-components --save

Usage

Typical Usage Example

import styled from 'styled-components';
import FloatingLabel from 'react-styled-floating-label';

const BlueFloatingLabel = styled(FloatingLabel)`
    color: #0070e0;
`;

const Input = styled.input`
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    box-sizing: border-box;

    border: none;
    border-bottom: 0.5px solid #bdbdbd;

    font-size: 1.25em;
    padding-left: 0.25em;
    padding-top: 0.25em;
    min-width: 20em;

    :focus {
        border-color: #5eaefe;
        outline: none;
    }
`;

const email = (
    <BlueFloatingLabel text="Email">
        <Input type="email" />
    </BlueFloatingLabel>
);

Typical Usage Screen Recording

Styling With Props

import FloatingLabel from 'react-styled-floating-label';

const address = (
    <FloatingLabel
        text="Address"
        style={{
            color: '#0070e0',
        }}
        placeholderStyle={{
            fontWeight: 'bold',
        }}>
        <Input />
    </FloatingLabel>
);

Styling With Props Screen Recording

Styled Placeholder

import styled from 'styled-components';
import FloatingLabel from 'react-styled-floating-label';

const FloatingLabelWithStyledPlaceholder = styled(FloatingLabel)`
    --placeholder-color: #328a09;
    --placeholder-font-weight: bold;
`;

const Input = styled.input`
    font-size: 1em;
`;

const address = (
    <FloatingLabelWithStyledPlaceholder text="Address">
        <Input />
    </FloatingLabelWithStyledPlaceholder>
);

Styled Placeholder Screen Recording

Custom Positioning

import styled from 'styled-components';
import FloatingLabel from 'react-styled-floating-label';

const VerticallyPositionedFloatingLabel = styled(FloatingLabel)`
    transform: translateY(-10px);
`;

const HorizontallyPositionedFloatingLabel = styled(FloatingLabel)`
    margin-left: 20px;
`;

const firstName = (
    <VerticallyPositionedFloatingLabel text="First Name">
        <Input />
    </VerticallyPositionedFloatingLabel>
);

const lastName = (
    <HorizontallyPositionedFloatingLabel text="Last Name">
        <Input />
    </HorizontallyPositionedFloatingLabel>
);

Custom Positioning Screen Recording

You can check all examples in action in this live demo.

API

Props

Prop Required Default Description
text Yes Label text
style Optional {} Label style for projects which are not using styled-components
placeholderStyle Optional {} Placeholder style for projects which are not using styled-components
container Optional div Component container
label Optional label Label component

styled-components

Label can be styled with styled-components:

import styled from 'styled-components';
import FloatingLabel from 'react-styled-floating-label';

const BlueFloatingLabel = styled(FloatingLabel)`
    color: #0070e0;
`;

To style placeholder use standard CSS properties with the "--placeholder-" prefix:

const BlueFloatingLabelWithBoldPlaceholder = styled(BlueFloatingLabel)`
    --placeholder-font-weight: bold;
`;

Demo

To run the demo, you need to clone the project and execute:

npm i && npm run demo

Or you can check a live demo here.

Feedback

There are no mailing lists or discussion groups yet. Please use GitHub issues and pull request or follow me on Twitter @IhorBurlachenko

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].