Quantcast
Channel: Active questions tagged blazor - Stack Overflow
Viewing all articles
Browse latest Browse all 4839

Extend InputRadio adding defult css style

$
0
0

I am trying to render a custom radio button in Blazor only adding a default css class to the component. So I thought I could just extend the InputRadio component and modify the css classes that are defined.

So I have a css class called "foo" and Im trying to make a custom component FooRadio by default have all the stuff with InputRadio but also class="foo". I dont want to have to actually add it manually.

I tried doing this..

@inherits InputRadio<TValue>@{   base.BuildRenderTree(__builder);}

Now I thought there may have been a Css property I could tap into and overwrite, but I dont seem to have access to one. The InputRadio does merge the AdditionalAttributes with the Context.FieldCss, but the only thing available for me is the AdditionalAttributes and it is a ReadOnly Dictionary. Also InputRadio requires a TValue, and I am not sure how to inherit it and also give it a TValue. I assume my custom Radio Button will need to have a as well.

So, I started just building a simple <input type="radio".../> but I dont know all the callbacks or bindings I will need to add in the component to make it function like the InputRadio.

I know InputRadio requires you to be inside an InputRadioGroup which is fine. Ideally Id like to be able to do something like this..

<InputRadioButtonGroup><InputRadio...><FooRadio...><InputRadio...></InputRadioButtonGroup>

Again, FooRadio and InputRadio will act the same. Its just FooRadio will have a css class of "foo" without actually declaring it on the FooRadio tag

Hope this is enough info. If not, I can give more info. Maybe I am approaching this in a much more complicated way than needs to be.

Thank you for any assistance.


Viewing all articles
Browse latest Browse all 4839

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>