26
Dec
07

Setting font weight on a Flex DateChooser control

The following example shows how you can set the fontWeight style on a Flex DateChooser control to change whether each day in the calendar appears as normal or bold font.

Full code after the jump.

View MXML

<?xml version="1.0" encoding="utf-8"?>
<!-- http://blog.flexexamples.com/2007/12/26/setting-font-weight-on-a-flex-datechooser-control/ -->
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
        layout="vertical"
        verticalAlign="middle"
        backgroundColor="white">

    <mx:Style>
        .myHeaderStyleName {
            color: red;
            fontWeight: normal;
        }

        .myWeekDayStyleName {
            color: haloOrange;
            fontWeight: normal;
        }
    </mx:Style>

    <mx:HBox id="box">
        <mx:VBox>
            <mx:Label text="fontWeight = bold" />
            <mx:DateChooser fontWeight="bold"
                    showToday="false" />
        </mx:VBox>
        <mx:VBox>
            <mx:Label text="fontWeight = normal" />
            <mx:DateChooser fontWeight="normal"
                    showToday="false" />
        </mx:VBox>
        <mx:VBox>
            <mx:Label text="custom styles" />
            <mx:DateChooser color="haloGreen"
                    showToday="false"
                    headerStyleName="myHeaderStyleName"
                    weekDayStyleName="myWeekDayStyleName" />
        </mx:VBox>
    </mx:HBox>

</mx:Application>

View source is enabled in the following example.

If you want to set the font weight for the calendar, header, and week days using CSS, you can use the following snippet:

<mx:Style>
    DateChooser {
        fontWeight: normal;
        headerStyleName: normalWeight;
        weekDayStyleName: normalWeight;
    }

    .normalWeight {
        fontWeight: normal;
    }
</mx:Style>

<mx:DateChooser />

2 Responses to “Setting font weight on a Flex DateChooser control”


  1. 1 molaro Feb 6th, 2008 at 11:43 am

    So is there a way to bold only certain dates? In my application, I use a date chooser to allow users to see a list of “events” that occur on that date. I would like my calendar to highlight/bold/color differently or something for the days on the calendar that have dates. I am assuming I would make an array of my days with events and then somehow say “if day is in this array, apply this style”. Any help, or suggestions are appreciated. Thx!

  2. 2 peter Feb 10th, 2008 at 4:49 pm

    i would like to do the same.. if somebody has got a solution for this problem, please share it! thanks!

Leave a Reply

This blog is terrible at eating HTML tags. If you plan on posting code/XML, please escape your "<" characters as "&lt;" and your ">" characters as "&gt;".