React-big-calendar: Event Categories

Created on 23 Dec 2016  路  9Comments  路  Source: jquense/react-big-calendar

Is there a way to change the color of event title based on its category (.e.g. classes vs workshops etc)?

Right now all the event titles are the same color with the class name _rbc-event_ applied to every one.

I would love to be able to pass a category in with the event which would then put a category class on the event div so I could style it based on category.

Most helpful comment

Thank you.

For those that come after me and in the spirit of open source, I figured it out.

<BigCalendar
          eventPropGetter={event => ({className: 'category-' + event.category.toLowerCase()})}
          events={events}
/>

Make sure category is defined in the events you pass in.

All 9 comments

yup, you can provide any class or style you want via the eventPropGetter prop

Can you provide an example? I don't understand how to use that.

it's a function that is passed the event and returns an object with a className abd/or style prop. the API docs describe the prop , you can poke through the source for more info

Thank you.

For those that come after me and in the spirit of open source, I figured it out.

<BigCalendar
          eventPropGetter={event => ({className: 'category-' + event.category.toLowerCase()})}
          events={events}
/>

Make sure category is defined in the events you pass in.

Thanks for this :)

This was really helpful! Maybe add an example to the docs?

that's be great! want to send a PR for it?

Let me play around with it, get comfortable with everything it can do and I'll make one!

let me know if you have any questions. docs are generated from the comments in Calendar.js

Was this page helpful?
0 / 5 - 0 ratings

Related issues

kromit picture kromit  路  4Comments

mathieusanchez picture mathieusanchez  路  4Comments

npalansky picture npalansky  路  3Comments

martinnov92 picture martinnov92  路  3Comments

jgautsch picture jgautsch  路  3Comments