The following link shows the state level laws in California for accessory dwelling units:
https://leginfo.legislature.ca.gov/faces/billCompareClient.xhtml?bill_id=201520160AB2299.

Click here for pending legislation to this law.

Your county and town may have additional regulations. Be sure to check before building.