Coder Social home page Coder Social logo

snowcoders / react-unstyled-button Goto Github PK

View Code? Open in Web Editor NEW
1.0 3.0 1.0 4.46 MB

React component that renders a html button where all the browser styles have been removed

License: MIT License

CSS 0.43% TypeScript 56.96% JavaScript 38.45% SCSS 4.16%

react-unstyled-button's Introduction

Deprecation

The majority of what this package did is remove the styling of the default html button. However now that IE 11 is deprecated, the css property all: unset works across enough browsers that it doesn't make sense to maintain this project.

input[type=button],
input[type=submit],
button {
  all: unset;
}

npm (scoped) CircleCI branch

Use it

npm install --save @snowcoders/react-unstyled-button

import { UnstyledButton } from "@snowcoders/react-unstyled-button";
import "@snowcoders/react-unstyled-button/styles.css";

render() {
    <UnstyledButton
        onClick={this.onClick}
    >
        Button text
    </UnstyledButton>
}

Adding custom styling

Custom styling can be applied via specificity

// green-button.css
.sci-react-unstyled-button.green-button {
  // Box-Sizing
  padding: 14px 40px;
  border-radius: 100px;
  border-width: 0px;
  border-style: solid;

  // Colors
  border-color: #16da00;
  background-color: green;
  color: white;

  // Sizes
  font-size: 16px;
  font-family: "Open Sans", X-LocaleSpecific, sans-serif;

  &:hover {
    background-color: darkgreen;
  }
}
// green-button.js
import { UnstyledButton } from "@snowcoders/react-unstyled-button";
import "@snowcoders/react-unstyled-button/styles.css";
import "./green-button.css";

render() {
    <UnstyledButton
        className="green-button"
        onClick={this.onClick}
    >
        Button text
    </UnstyledButton>
}

Parent Library

This component is part of a larger components library, react-ui-base. The goal is to keep all the core logic and base css styles in a single location, that way building out new UI component libraries cheaper and faster (and less buggy).

We highly recommend visiting the react-ui-base repository to understand how to customize the css along with see examples.

You can also view all the components on our demo site https://snowcoders.github.io/react-ui-base/

This component

This component takes the normal HTML Button element and removes all browser styling from it.

react-unstyled-button's People

Contributors

renovate-bot avatar k2snowman69 avatar ritcheyer avatar

Stargazers

 avatar

Watchers

James Cloos avatar  avatar  avatar

Forkers

ritcheyer

react-unstyled-button's Issues

Deprecate this for a css only solution

This package ties together react + css which is not ideal.

Instead, a package that contains several css files to be able to remove styling makes more sense and then can be used in Vue, Angular and React packages.

Passing disabled=true doesn't add the disabled attribute on the button

<div class="sci-react-checkbox uber-tofu-checkbox disabled tofu-checkbox">
   <label class="content">
      <button class="sci-react-unstyled-button visual">

Should render

<div class="sci-react-checkbox uber-tofu-checkbox disabled tofu-checkbox">
   <label class="content">
      <button class="sci-react-unstyled-button visual" disabled>

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.