Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tomlm/BlazorCss

Blazor Component to create data bound CSS rules
https://github.com/tomlm/BlazorCss

blazor css

Last synced: about 2 months ago
JSON representation

Blazor Component to create data bound CSS rules

Awesome Lists containing this project

README

        



# BlazorCss
This is a Blazor Library which adds data bound style rules to the BlazorStyled library (see https://blazorstyled.io/)

With this library you get
* Component for defining a rule
* CSS properties are autocompleted
* Constants are available for auto completion

![alt text](https://github.com/tomlm/BlazorCss/raw/master/NameCompletion.png)
![alt text](https://github.com/tomlm/BlazorCss/raw/master/ValueCompletion.png)

## Installation
```
dotnet add package BlazorCss
```

## Usage
There are 2 ways to use it, as a way to define the properties of the Styled component it is in, or as a way to define
a specific selector and the style properties of the selector.

### Root level rule
As a root level rule. All attributes on the rule apply to the class name of the Styled tag

```html

```

This generates:
```css
.foo {
background: Pink;
display: grid;
height: 300px;
}
```

### Selector based rule
If you use the Selector attribute you can define a selector for the attributes.

```html

```

In this case it generates a CSS selector rule for the element with Id **blat**:
```css
#blat {
display: grid;
background: yello;
align-content: space-around;
}
```
Any valid CSS selector can be put into the Selector property, such as
* *div > a*
* *.foo,.bar*
* etc.

> NOTE: Backing properties in C# can't have a dash in the name, so the attributes with dash are represented with underscore.
> align_content ==> align-content in the css