DEV Community

Takane Ichinose
Takane Ichinose

Posted on

1

3D Button with Shading (Experiment)

Experimenting 3D Button with Shading

I'm just experimenting with shading, and coloring.

I used the colors in "assets" for the colors of these buttons.

The colors of the buttons are just inspired by most of the CSS frameworks out there. As well as the naming of the classes.

This list is the allowed class name for the buttons

  1. btn
  2. btn btn-info
  3. btn btn-success
  4. btn btn-warning
  5. btn btn-error
  6. btn btn-dark

I just did similar shading technique with my previous pen. Please check it if you haven't yet.

The font color, background-color, and the border-color is customizable by adding class attribute on the HTML element, or by setting it on the CSS class.

As of now, I allowed these 3 variables to be customizable:

  1. color
  2. background-color
  3. border-color

Example usage

<!--This is the default usage, where we can use the prepared color by its class name-->
<button class="btn btn-info">Information button</button>

<!--This is the altered usage, by setting the style attribute of the HTML element-->
<button class="btn" style="--background-color: green;">Information button</button>

IF YOU WANT TO USE THIS STYLE, PLEASE READ THIS

This is written in SCSS. If you would like to use the CSS, you may compile the code, then use the CSS style on your own project.

Please take note that the code above the block of comment:

STYLES RELATED TO EXPERIMENT BUTTONS

is just for the styling of the page. These are not related to the styles of the buttons. So after compiling to CSS, you may just take the part on or below the said block of comments.

You may also customize the colors of the buttons, or actually add a new class for the buttons, by editing the $btn-type map before compiling the source code into CSS.

Image of Datadog

Create and maintain end-to-end frontend tests

Learn best practices on creating frontend tests, testing on-premise apps, integrating tests into your CI/CD pipeline, and using Datadog’s testing tunnel.

Download The Guide

Top comments (0)

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Best practices for optimal infrastructure performance with Magento

Running a Magento store? Struggling with performance bottlenecks? Join us and get actionable insights and real-world strategies to keep your store fast and reliable.

Tune in to the full event

DEV is partnering to bring live events to the community. Join us or dismiss this billboard if you're not interested. ❤️